
<!DOCTYPE HTML>
<html lang="zh" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>类型系统 · Pine Script 用户手册中文版</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="剑客">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="7operator.html" />
    
    
    <link rel="prev" href="5line.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="輸入並搜尋" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Introduction.html">
            
                <a href="../Introduction.html">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../quickstart/">
            
                <a href="../quickstart/">
            
                    
                    快速开始
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../quickstart/example.html">
            
                <a href="../quickstart/example.html">
            
                    
                    Pine Script 示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../quickstart/studyVsStrategy.html">
            
                <a href="../quickstart/studyVsStrategy.html">
            
                    
                    “study” 与 “strategy”
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../quickstart/model.html">
            
                <a href="../quickstart/model.html">
            
                    
                    Pine Script 执行模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../quickstart/series.html">
            
                <a href="../quickstart/series.html">
            
                    
                    序列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../quickstart/understanding.html">
            
                <a href="../quickstart/understanding.html">
            
                    
                    理解 Pine Script
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../quickstart/editor.html">
            
                <a href="../quickstart/editor.html">
            
                    
                    Pine 编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../quickstart/next.html">
            
                <a href="../quickstart/next.html">
            
                    
                    下一步
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    语言基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="1structure.html">
            
                <a href="1structure.html">
            
                    
                    脚本结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="2version.html">
            
                <a href="2version.html">
            
                    
                    版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="3comment.html">
            
                <a href="3comment.html">
            
                    
                    注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="4identifier.html">
            
                <a href="4identifier.html">
            
                    
                    标识符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="5line.html">
            
                <a href="5line.html">
            
                    
                    换行
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.6" data-path="6type.html">
            
                <a href="6type.html">
            
                    
                    类型系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="7operator.html">
            
                <a href="7operator.html">
            
                    
                    运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="8function.html">
            
                <a href="8function.html">
            
                    
                    函数和注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="9expressions.html">
            
                <a href="9expressions.html">
            
                    
                    表达式、声明和语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="10function.html">
            
                <a href="10function.html">
            
                    
                    函数声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="11model.html">
            
                <a href="11model.html">
            
                    
                    执行模型
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../features/">
            
                <a href="../features/">
            
                    
                    基本功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../features/1alert.html">
            
                <a href="../features/1alert.html">
            
                    
                    警报
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../features/2array.html">
            
                <a href="../features/2array.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../features/3barstate.html">
            
                <a href="../features/3barstate.html">
            
                    
                    柱状态，内置变量 barstate.*
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../features/4color.html">
            
                <a href="../features/4color.html">
            
                    
                    颜色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../features/5context.html">
            
                <a href="../features/5context.html">
            
                    
                    上下文切换和 security 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../features/6drawing.html">
            
                <a href="../features/6drawing.html">
            
                    
                    绘图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../features/7extend.html">
            
                <a href="../features/7extend.html">
            
                    
                    延长和扩展交易数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../features/8reapint.html">
            
                <a href="../features/8reapint.html">
            
                    
                    指标重绘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../features/9nonstandard.html">
            
                <a href="../features/9nonstandard.html">
            
                    
                    非标准图表类型数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../features/10session.html">
            
                <a href="../features/10session.html">
            
                    
                    交易时段和时间信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../features/11strategies.html">
            
                <a href="../features/11strategies.html">
            
                    
                    策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../features/12table.html">
            
                <a href="../features/12table.html">
            
                    
                    图表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../annotations/">
            
                <a href="../annotations/">
            
                    
                    注解概览
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../annotations/1study.html">
            
                <a href="../annotations/1study.html">
            
                    
                    指标注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../annotations/2plot.html">
            
                <a href="../annotations/2plot.html">
            
                    
                    绘图注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../annotations/3input.html">
            
                <a href="../annotations/3input.html">
            
                    
                    脚本输入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../annotations/4price.html">
            
                <a href="../annotations/4price.html">
            
                    
                    价格水平，hline
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../annotations/5fill.html">
            
                <a href="../annotations/5fill.html">
            
                    
                    用 fill 填充背景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../annotations/6barcolor.html">
            
                <a href="../annotations/6barcolor.html">
            
                    
                    使用 barcolor 为 series 着色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../annotations/7bg.html">
            
                <a href="../annotations/7bg.html">
            
                    
                    使用 bgcolor 进行背景着色
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../annotations/8shape.html">
            
                <a href="../annotations/8shape.html">
            
                    
                    绘制形状、字符和箭头
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../annotations/9custom.html">
            
                <a href="../annotations/9custom.html">
            
                    
                    定制 OHLC 柱和蜡烛
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../debugging/">
            
                <a href="../debugging/">
            
                    
                    调试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../debugging/1introduction.html">
            
                <a href="../debugging/1introduction.html">
            
                    
                    指标注解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../debugging/2land.html">
            
                <a href="../debugging/2land.html">
            
                    
                    功能位置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../debugging/3num.html">
            
                <a href="../debugging/3num.html">
            
                    
                    显示数值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../debugging/4str.html">
            
                <a href="../debugging/4str.html">
            
                    
                    显示字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../debugging/5conditions.html">
            
                <a href="../debugging/5conditions.html">
            
                    
                    调试条件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../debugging/6fn.html">
            
                <a href="../debugging/6fn.html">
            
                    
                    从内部函数调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../debugging/7for.html">
            
                <a href="../debugging/7for.html">
            
                    
                    从“for”循环内部调试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../debugging/8tips.html">
            
                <a href="../debugging/8tips.html">
            
                    
                    提示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../publishing/">
            
                <a href="../publishing/">
            
                    
                    发布脚本
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../publishing/1pvp.html">
            
                <a href="../publishing/1pvp.html">
            
                    
                    公共脚本与私有脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../publishing/2mode.html">
            
                <a href="../publishing/2mode.html">
            
                    
                    发布模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../publishing/3ps.html">
            
                <a href="../publishing/3ps.html">
            
                    
                    如何发布脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../publishing/4us.html">
            
                <a href="../publishing/4us.html">
            
                    
                    如何更新脚本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../library/">
            
                <a href="../library/">
            
                    
                    公共库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../library/1description.html">
            
                <a href="../library/1description.html">
            
                    
                    描述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../library/2copy.html">
            
                <a href="../library/2copy.html">
            
                    
                    将脚本从公共库复制到您的个人库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../library/3editing.html">
            
                <a href="../library/3editing.html">
            
                    
                    编辑来自公共库的脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../library/4searching.html">
            
                <a href="../library/4searching.html">
            
                    
                    搜索脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../library/5video.html">
            
                <a href="../library/5video.html">
            
                    
                    教学视频
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../appendix/">
            
                <a href="../appendix/">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../appendix/1migration.html">
            
                <a href="../appendix/1migration.html">
            
                    
                    Pine 第 3 版迁移指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../appendix/2how.html">
            
                <a href="../appendix/2how.html">
            
                    
                    操作指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../appendix/3err.html">
            
                <a href="../appendix/3err.html">
            
                    
                    Pine 的编译和执行错误
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../more/">
            
                <a href="../more/">
            
                    
                    我可以从哪里获得更多信息？
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本書使用 GitBook 釋出
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >类型系统</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;">&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;</h1>
<p>Pine &#x6709; 9 &#x79CD;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;&#x5B83;&#x4EEC;&#x662F;&#xFF1A; int&#x3001;float&#x3001;bool&#x3001;color&#x3001;string&#x3001;line&#x3001;label&#x3001;plot&#x3001;hline&#x3002;&#x7C7B;&#x578B;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#xFF1A; literal, const, input, simple &#x548C; series&#x3002;&#x6211;&#x4EEC;&#x7ECF;&#x5E38;&#x5C06;&#x6210;&#x5BF9;&#x5F62;&#x5F0F;&#x7C7B;&#x578B;&#x79F0;&#x4E3A;&#x7C7B;&#x578B;&#x3002;Pine &#x7F16;&#x8BD1;&#x5668;&#x533A;&#x5206;&#x6587;&#x5B57;  bool &#x7C7B;&#x578B;&#x3001;input bool &#x7C7B;&#x578B;&#xFF0C; series bool &#x7C7B;&#x578B;&#x7B49;&#x7B49;&#x3002;</p>
<p>&#x8FD8;&#x6709;&#x6570;&#x7EC4;&#x7C7B;&#x578B;&#xFF0C;void &#x7C7B;&#x578B;&#xFF0C; na&#xFF08;&#x4E0D;&#x53EF;&#x7528;&#xFF09;&#x503C;&#x548C;&#x4E00;&#x4E2A;&#x590D;&#x5408;&#x5143;&#x7EC4;&#x7C7B;&#x578B;&#x3002;</p>
<h2 id="&#x7C7B;&#x578B;&#x5F62;&#x5F0F;">&#x7C7B;&#x578B;&#x5F62;&#x5F0F;</h2>
<h3 id="literal-&#x5B57;&#x9762;&#x91CF;">literal &#x5B57;&#x9762;&#x91CF;</h3>
<p>literal &#x7528;&#x4E8E;&#x8868;&#x793A;&#x5728; Pine &#x7684;&#x56FA;&#x5B9A;&#x503C;&#x7684;&#x7279;&#x6B8A;&#x7B26;&#x53F7;&#x3002;&#x8FD9;&#x4E2A;&#x56FA;&#x5B9A;&#x503C;&#x672C;&#x8EAB;&#x662F;&#x4E00;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x6587;&#x5B57;&#x8868;&#x8FBE;&#x5F0F;&#x603B;&#x662F;&#x4EE5;&#x4E0B; 5 &#x79CD;&#x7C7B;&#x578B;&#x4E4B;&#x4E00;&#xFF1A;</p>
<ul>
<li>literal float (3.14, 6.02E-23, 3e8)</li>
<li>literal int (42)</li>
<li>literal bool (true, false)</li>
<li>literal string (&quot;A text literal&quot;)</li>
<li>literal color (#FF55C6)</li>
</ul>
<hr>
<blockquote>
<p>&#x6CE8;&#x610F;<br>&#x5728; Pine &#x4E2D;&#xFF0C;&#x5185;&#x7F6E;&#x53D8;&#x91CF; open, high, low, close, volume, time, hl2, hlc3, ohlc4 &#x4E0D;&#x662F; literal&#x3002;&#x5B83;&#x4EEC;&#x662F; series &#x5F62;&#x5F0F;&#x3002;</p>
</blockquote>
<hr>
<h3 id="const-&#x5E38;&#x91CF;">const &#x5E38;&#x91CF;</h3>
<p>const &#x5F62;&#x5F0F;&#x7684;&#x503C;&#xFF1A;</p>
<ul>
<li>&#x5728;&#x811A;&#x672C;&#x6267;&#x884C;&#x671F;&#x95F4;&#x4E0D;&#x80FD;&#x66F4;&#x6539;</li>
<li>&#x5DF2;&#x77E5;&#x91CF;&#x6216;&#x53EF;&#x4EE5;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x8BA1;&#x7B97;&#x7684;&#x91CF;</li>
</ul>
<p>&#x5982;&#xFF1A;</p>
<pre><code>c1 = 0
c2 = c1 + 1
c3 = c1 + 1
if open &gt; close
    c3 := 0
</code></pre><p>c1 &#x7684;&#x7C7B;&#x578B;&#x662F; const int&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x662F;&#x7528; literal int &#x521D;&#x59CB;&#x5316;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x3002;c2 &#x7684;&#x7C7B;&#x578B;&#x4E5F;&#x662F; const int&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x662F;&#x7528; const int &#x7C7B;&#x578B;&#x7684;&#x7B97;&#x672F;&#x8868;&#x8FBE;&#x5F0F;&#x521D;&#x59CB;&#x5316;&#x7684;&#x3002;c3 &#x7684;&#x7C7B;&#x578B;&#x4E3A; series int &#x56E0;&#x4E3A;&#x5B83;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x4F1A;&#x66F4;&#x6539;&#x3002;</p>
<h3 id="input-&#x8F93;&#x5165;">input &#x8F93;&#x5165;</h3>
<p>&#x8868;&#x5355;&#x8F93;&#x5165;&#x7684;&#x503C;&#xFF1A;</p>
<ul>
<li>&#x5728;&#x811A;&#x672C;&#x6267;&#x884C;&#x65F6;&#x4E0D;&#x80FD;&#x66F4;&#x6539;</li>
<li>&#x7F16;&#x8BD1;&#x65F6;&#x672A;&#x77E5;</li>
<li>&#x6E90;&#x81EA;&#x8F93;&#x5165;&#x51FD;&#x6570;</li>
</ul>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>p = input(10, title=&quot;Period&quot;)
</code></pre><p>&#x53D8;&#x91CF; p &#x7684;&#x7C7B;&#x578B;&#x662F; input int&#x3002;</p>
<h3 id="simple-&#xFF08;&#x8FD9;&#x91CC;&#x5E94;&#x8BE5;&#x662F;&#x666E;&#x901A;&#x6216;&#x6B63;&#x5E38;&#x7684;&#x610F;&#x601D;&#xFF09;">simple &#xFF08;&#x8FD9;&#x91CC;&#x5E94;&#x8BE5;&#x662F;&#x666E;&#x901A;&#x6216;&#x6B63;&#x5E38;&#x7684;&#x610F;&#x601D;&#xFF09;</h3>
<p>simple&#x5F62;&#x5F0F;&#x7684;&#x503C;:</p>
<ul>
<li>&#x5728;&#x811A;&#x672C;&#x6267;&#x884C;&#x65F6;&#x4E0D;&#x80FD;&#x66F4;&#x6539;</li>
<li>&#x7F16;&#x8BD1;&#x65F6;&#x672A;&#x77E5;</li>
</ul>
<p>&#x5B83;&#x4EEC;&#x662F;&#x6765;&#x81EA;&#x4E3B;&#x56FE;&#x8868;&#x4EA4;&#x6613;&#x54C1;&#x79CD;&#x4FE1;&#x606F;&#x7684;&#x503C;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x5185;&#x7F6E;&#x53D8;&#x91CF; syminfo.mintick &#x662F;&#x4E00;&#x4E2A; simple float&#x3002;&#x63D0;&#x5230;&#x8FD9;&#x79CD;&#x5F62;&#x5F0F;&#x65F6;&#xFF0C;&#x5355;&#x8BCD; simple &#x901A;&#x5E38;&#x4F1A;&#x88AB;&#x7701;&#x7565;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x4F7F;&#x7528; float &#x800C;&#x4E0D;&#x662F; simple float&#x3002;</p>
<h3 id="series-&#x5E8F;&#x5217;">series &#x5E8F;&#x5217;</h3>
<p>&#x8868;&#x5355;&#x5E8F;&#x5217;&#x7684;&#x503C;&#xFF1A;</p>
<ul>
<li>&#x811A;&#x672C;&#x6267;&#x884C;&#x671F;&#x95F4;&#x53EF;&#x4EE5;&#x66F4;&#x6539;</li>
<li>&#x50A8;&#x5B58;&#x4E8E;&#x4E3B;&#x56FE;&#x8868;&#x4EA4;&#x6613;&#x54C1;&#x79CD;&#x7684; k &#x7EBF;&#x76F8;&#x5173;&#x7684;&#x4E00;&#x7CFB;&#x5217;&#x5386;&#x53F2;&#x503C;</li>
<li>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; [] &#x64CD;&#x4F5C;&#x7B26;&#x8FDB;&#x884C;&#x8BBF;&#x95EE;&#x3002;&#x6CE8;&#x610F;&#xFF1A;&#x53EA;&#x6709; series &#x4E2D;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x5373;&#x4E0E;&#x5F53;&#x524D; k &#x7EBF;&#x76F8;&#x5173;&#x8054;&#x7684;&#x503C;&#x624D;&#x53EF;&#x7528;&#x4E8E;&#x8BFB;&#x5199;</li>
</ul>
<p>series &#x5F62;&#x5F0F;&#x662F; Pine &#x4E2D;&#x7684;&#x6700;&#x5E38;&#x89C1;&#x5F62;&#x5F0F;&#x3002;series &#x7C7B;&#x578B;&#x7684;&#x5185;&#x7F6E;&#x53D8;&#x91CF;&#x6709;&#xFF1A;open&#xFF0C;high&#xFF0C;low&#xFF0C; close&#xFF0C;volume &#x548C; time&#x3002;&#x8FD9;&#x4E9B; series &#x7684;&#x957F;&#x5EA6;&#x7B49;&#x4E8E;&#x5F53;&#x524D;&#x4EE3;&#x7801;&#x548C;&#x65F6;&#x95F4;&#x8303;&#x56F4;&#xFF08;k &#x7EBF;&#x7EA7;&#x522B;&#xFF09;&#x7684;&#x53EF;&#x7528;&#x67F1;&#x6570;&#x3002;series &#x53EF;&#x80FD;&#x5305;&#x542B;&#x6570;&#x5B57;&#x6216;&#x7279;&#x6B8A;&#x503C;&#xFF1A;na&#xFF0C;&#x8868;&#x793A;&#x503C;&#x4E0D;&#x53EF;&#x7528;&#x3002;na &#x53EF;&#x4EE5;&#x5728;&#x6B64;&#x5904;&#x627E;&#x5230;&#x6709;&#x5173;&#x8BE5;&#x503C;&#x7684;&#x66F4;&#x591A;&#x4FE1;&#x606F;&#x3002;&#x4EFB;&#x4F55;&#x5305;&#x542B; series &#x53D8;&#x91CF;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x90FD;&#x5C06;&#x88AB;&#x89C6;&#x4E3A;&#x7CFB;&#x5217;&#x672C;&#x8EAB;&#x3002;
<!-- todo: 链接 -->
&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>a = open + close // Addition of two series
b = high / 2     // Division of a series variable by
                 // an integer literal constant
c = close[1]     // Referring to the previous ``close`` value
</code></pre><hr>
<blockquote>
<p>&#x6CE8;&#x610F;<br>[ ] &#x8FD0;&#x7B97;&#x7B26;&#x8FD4;&#x56DE; series &#x5F62;&#x5F0F;&#x7684;&#x503C;&#x3002;</p>
</blockquote>
<hr>
<h2 id="&#x57FA;&#x672C;&#x7C7B;&#x578B;">&#x57FA;&#x672C;&#x7C7B;&#x578B;</h2>
<h3 id="int-&#x6574;&#x6570;">int &#x6574;&#x6570;</h3>
<p>&#x6574;&#x6570;&#x6587;&#x5B57;&#x5FC5;&#x987B;&#x7528;&#x5341;&#x8FDB;&#x5236;&#x8868;&#x793A;&#x6CD5;&#x4E66;&#x5199;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>1
750
94572
100
</code></pre><p>Pine &#x4E2D;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#x7684; int &#x7C7B;&#x578B;&#xFF1A;</p>
<ul>
<li>literal int</li>
<li>const int</li>
<li>input int</li>
<li>int</li>
<li>series int</li>
</ul>
<h3 id="float-&#x6D6E;&#x70B9;&#x6570;">float &#x6D6E;&#x70B9;&#x6570;</h3>
<p>&#x6D6E;&#x70B9;&#x6570;&#x5305;&#x542B;&#x5206;&#x9694;&#x7B26;&#xFF08;&#x7B26;&#x53F7;.&#xFF09;&#xFF0C;&#x4E5F;&#x53EF;&#x80FD;&#x5305;&#x542B;&#x7B26;&#x53F7; e &#xFF08;&#x610F;&#x601D;&#x662F;&#x201C;&#x4E58;&#x4EE5; 10 &#x7684; X &#x6B21;&#x65B9;&#x201D;&#xFF0C;&#x5176;&#x4E2D; X &#x662F;&#x7B26;&#x53F7;&#x4E4B;&#x540E;&#x7684;&#x6570;&#x5B57; e&#xFF09;&#x3002;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>3.14159    // 3.14159
6.02e23    // 6.02 * 10^23
1.6e-19    // 1.6 * 10^-19
3.0        // 3.0
</code></pre><p>&#x7B2C;&#x4E00;&#x4E2A;&#x6570;&#x5B57;&#x662F;&#x56DB;&#x820D;&#x4E94;&#x5165;&#x7684;&#x6570;&#x5B57; Pi (&#x3C0;)&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x6570;&#x5B57;&#x5F88;&#x5927;&#xFF0C;&#x800C;&#x7B2C;&#x4E09;&#x4E2A;&#x6570;&#x5B57;&#x5F88;&#x5C0F;&#x3002;&#x7B2C;&#x56DB;&#x4E2A;&#x6570;&#x5B57;&#x53EA;&#x662F; 3 &#x4F5C;&#x4E3A;&#x6D6E;&#x70B9;&#x6570;&#x7684;&#x6570;&#x5B57;&#x3002;</p>
<hr>
<blockquote>
<p>&#x6CE8;&#x610F;<br>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5927;&#x5199; E &#x4EE3;&#x66FF;&#x5C0F;&#x5199; e&#x3002;</p>
</blockquote>
<hr>
<p>Pine &#x4E2D;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#x7684; float &#x7C7B;&#x578B;&#xFF1A;</p>
<ul>
<li>literal float</li>
<li>const float</li>
<li>input float</li>
<li>float</li>
<li>series float</li>
</ul>
<p>Pine &#x4E2D;&#x6D6E;&#x70B9;&#x6570;&#x7684;&#x5185;&#x90E8;&#x7CBE;&#x5EA6;&#x4E3A; 1e-10&#x3002;</p>
<h3 id="bool-&#x5E03;&#x5C14;&#x503C;">bool &#x5E03;&#x5C14;&#x503C;</h3>
<p>&#x5E03;&#x5C14;&#x503C;&#x53EA;&#x6709;&#x4E24;&#x79CD;&#x5B57;&#x9762;&#x91CF;&#xFF1A;</p>
<pre><code>true    // true value
false   // false value
</code></pre><p>Pine &#x4E2D;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#x7684; bool &#x7C7B;&#x578B;&#xFF1A;</p>
<ul>
<li>literal bool</li>
<li>const bool</li>
<li>input bool</li>
<li>bool</li>
<li>series bool</li>
</ul>
<h3 id="color-&#x989C;&#x8272;">color &#x989C;&#x8272;</h3>
<p>&#x989C;&#x8272;&#x5B57;&#x9762;&#x91CF;&#x5177;&#x6709;&#x4EE5;&#x4E0B;&#x683C;&#x5F0F;&#xFF1A;#&#x540E;&#x8DDF; 6 &#x6216; 8 &#x4E2A;&#x4E0E; RGB &#x6216; RGBA &#x503C;&#x5339;&#x914D;&#x7684;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x6570;&#x5B57;&#x3002;&#x524D;&#x4E24;&#x4F4D;&#x6570;&#x5B57;&#x786E;&#x5B9A;&#x7EA2;&#x8272;&#x5206;&#x91CF;&#x7684;&#x503C;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x4E24;&#x4F4D;&#x662F;&#x7EFF;&#x8272;&#x5206;&#x91CF;&#xFF0C;&#x540E;&#x9762;&#x662F;&#x84DD;&#x8272;&#x5206;&#x91CF;&#x3002;&#x6BCF;&#x4E2A;&#x5206;&#x91CF;&#x503C;&#x5FC5;&#x987B;&#x662F;&#x4ECE; 00 &#x5230; FF &#xFF08;&#x5341;&#x8FDB;&#x5236;&#x7684; 0 &#x5230; 255&#xFF09;&#x7684;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x6570;&#x3002;</p>
<p>&#x7B2C;&#x56DB;&#x5BF9;&#x6570;&#x5B57;&#x662F;&#x53EF;&#x9009;&#x7684;&#x3002;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;&#x5B83;&#x6307;&#x5B9A; alpha&#xFF08;&#x4E0D;&#x900F;&#x660E;&#x5EA6;&#xFF09;&#x5206;&#x91CF;&#xFF0C;&#x4E00;&#x4E2A;&#x503C;&#x4E5F;&#x4ECE; 00 &#x5B8C;&#x5168;&#x900F;&#x660E;&#xFF09;&#x5230; FF&#xFF08;&#x5B8C;&#x5168;&#x4E0D;&#x900F;&#x660E;&#xFF09;&#x3002;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>#000000                // black color
#FF0000                // red color
#00FF00                // green color
#0000FF                // blue color
#FFFFFF                // white color
#808080                // gray color
#3ff7a0                // some custom color
#FF000080              // 50% transparent red color
#FF0000FF              // same as #FF0000, fully opaque red color
#FF000000              // completely transparent color
</code></pre><hr>
<blockquote>
<p>&#x6CE8;&#x610F;<br>&#x5341;&#x516D;&#x8FDB;&#x5236;&#x8868;&#x793A;&#x6CD5;&#x4E0D;&#x533A;&#x5206;&#x5927;&#x5C0F;&#x5199;&#x3002;</p>
</blockquote>
<hr>
<p>Pine &#x4E2D;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#x7684; color &#x7C7B;&#x578B;&#xFF1A;</p>
<ul>
<li>literal color</li>
<li>const color</li>
<li>input color</li>
<li>color</li>
<li>series color</li>
</ul>
<p>&#x95EE;&#xFF1A;&#x5982;&#x679C;&#x4E0D;&#x53EF;&#x80FD;&#x5728; Pine &#x4E2D;&#x4F7F;&#x7528; input &#x6765;&#x8F93;&#x5165;&#x989C;&#x8272;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x503C;&#x5982;&#x4F55;&#x6210;&#x4E3A; input color &#x7C7B;&#x578B;&#x3002;&#x7B54;&#xFF1A;&#x901A;&#x8FC7;&#x5177;&#x6709;&#x5176;&#x4ED6; input &#x7C7B;&#x578B;&#x548C; color &#x5B57;&#x9762;&#x91CF; / &#x5E38;&#x91CF;&#x7684;&#x7B97;&#x672F;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>b = input(true, &quot;Use red color&quot;)
c = b ? color.red : #000000  // c has color input type
</code></pre><p>&#x8FD9;&#x91CC;&#x4F7F;&#x7528; Pine &#x7684;&#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26; ?:&#xFF0C;&#x7528;&#x4E86;&#x4E09;&#x4E2A;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x503C;&#xFF1A;b &#x7684;&#x7C7B;&#x578B;&#x662F; input bool&#xFF0C;color.red &#x7684;&#x7C7B;&#x578B;&#x662F; const color &#x548C; #000000 &#x7684;&#x7C7B;&#x578B;&#x662F; literal color&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x8003;&#x8651;&#x5176;&#x81EA;&#x52A8;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x89C4;&#x5219;&#xFF08;&#x53C2;&#x89C1;&#x672C;&#x8282;&#x672B;&#x5C3E;&#xFF09;&#x548C; ?: &#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x53EF;&#x7528;&#x91CD;&#x8F7D;&#x3002;&#x7ED3;&#x679C;&#x7C7B;&#x578B;&#x662F;&#x7B26;&#x5408;&#x8FD9;&#x4E9B;&#x6761;&#x4EF6;&#x7684;&#x6700;&#x7A84;&#x7C7B;&#x578B;&#xFF1A;input color&#x3002;</p>
<p>&#x4EE5;&#x4E0B;&#x5185;&#x7F6E;&#x989C;&#x8272;&#x53D8;&#x91CF;&#x53EF;&#x7528;&#x4E8E;&#x66FF;&#x4EE3;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x7684; literal color&#xFF1A;color.black, color.silver, color.gray, color.white, color.maroon, color.red, color.purple, color.fuchsia, color.green, color.lime, color.olive, color.yellow, color.navy, color.blue, color.teal, color.aqua, color.orange.</p>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5185;&#x7F6E;&#x51FD;&#x6570; color.new &#x66F4;&#x6539;&#x989C;&#x8272;&#x7684;&#x900F;&#x660E;&#x5EA6;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>//@version=4
study(title=&quot;Shading the chart&apos;s background&quot;, overlay=true)
c = color.navy
bgColor = (dayofweek == dayofweek.monday) ? color.new(c, 50) :
          (dayofweek == dayofweek.tuesday) ? color.new(c, 60) :
          (dayofweek == dayofweek.wednesday) ? color.new(c, 70) :
          (dayofweek == dayofweek.thursday) ? color.new(c, 80) :
          (dayofweek == dayofweek.friday) ? color.new(c, 90) :
          color.new(color.blue, 80)
bgcolor(color=bgColor)
</code></pre><h3 id="string-&#x5B57;&#x7B26;&#x4E32;">string &#x5B57;&#x7B26;&#x4E32;</h3>
<p>&#x5B57;&#x7B26;&#x4E32;&#x5B57;&#x9762;&#x91CF;&#x53EF;&#x4EE5;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CC;&#x5F15;&#x53F7;&#x62EC;&#x8D77;&#x6765;&#x3002;</p>
<p>&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>&quot;This is a double quoted string literal&quot;
&apos;This is a single quoted string literal&apos;
</code></pre><p>&#x5355;&#x5F15;&#x53F7;&#x548C;&#x53CC;&#x5F15;&#x53F7;&#x5728;&#x529F;&#x80FD;&#x4E0A;&#x662F;&#x7B49;&#x6548;&#x7684;&#x3002;&#x53CC;&#x5F15;&#x53F7;&#x5185;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x5355;&#x5F15;&#x53F7;&#xFF0C;&#x53CD;&#x4E4B;&#x4EA6;&#x7136;&#xFF1A;</p>
<pre><code>&quot;It&apos;s an example&quot;
&apos;The &quot;Star&quot; indicator&apos;
</code></pre><p>&#x5982;&#x679C;&#x9700;&#x8981;&#x5728;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x5305;&#x542B;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x5B9A;&#x754C;&#x7B26;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x5728;&#x5B83;&#x524D;&#x9762;&#x52A0;&#x4E0A;&#x53CD;&#x659C;&#x6760;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>&apos;It\&apos;s an example&apos;
&quot;The \&quot;Star\&quot; indicator&quot;
</code></pre><p>Pine &#x4E2D;&#x6709; 5 &#x79CD;&#x5F62;&#x5F0F;&#x7684; string &#x7C7B;&#x578B;&#xFF1A;</p>
<ul>
<li>literal string</li>
<li>const string</li>
<li>input string</li>
<li>string</li>
<li>series string</li>
</ul>
<h3 id="line-&#x548C;-label">line &#x548C; label</h3>
<p>Pine v4 &#x4E2D;&#x5F15;&#x5165;&#x4E86;&#x65B0;&#x7684;&#x7ED8;&#x56FE;&#x5BF9;&#x8C61;&#x3002;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x662F;&#x4F7F;&#x7528; line.new &#x548C; label.new &#x51FD;&#x6570;&#x521B;&#x5EFA;&#x7684; &#x3002;&#x5B83;&#x4EEC;&#x7684;&#x7C7B;&#x578B;&#x5206;&#x522B;&#x662F; series line &#x548C; series label&#x3002;Pine &#x4E2D;&#x7684; line &#x548C; label &#x7C7B;&#x578B;&#x53EA;&#x6709;&#x4E00;&#x79CD;&#x5F62;&#x5F0F;&#xFF1A;series&#x3002;</p>
<h3 id="plot-&#x548C;-hline">plot &#x548C; hline</h3>
<p>&#x4E00;&#x4E9B;&#x51FD;&#x6570;&#xFF08;&#x7279;&#x522B;&#x662F; plot &#x548C; hline&#xFF09;&#x8FD4;&#x56DE;&#x8868;&#x793A;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x521B;&#x5EFA;&#x7684;&#x5BF9;&#x8C61;&#x7684;&#x503C;&#x3002;&#x51FD;&#x6570; plot &#x8FD4;&#x56DE;&#x4E00;&#x4E2A; plot &#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5728;&#x56FE;&#x8868;&#x4E0A;&#x8868;&#x793A;&#x4E3A;&#x4E00;&#x6761;&#x7EBF;&#x6216;&#x56FE;&#x3002;&#x51FD;&#x6570; hline &#x8FD4;&#x56DE;&#x4E00;&#x4E2A; hline &#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x8868;&#x793A;&#x4E3A;&#x4E00;&#x6761;&#x6C34;&#x5E73;&#x7EBF;&#x3002;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x4F20;&#x9012;&#x7ED9; fill &#x51FD;&#x6570;&#x6765;&#x4E3A;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x7684;&#x533A;&#x57DF;&#x7740;&#x8272;&#x3002;</p>
<h2 id="array-&#x6570;&#x7EC4;">array &#x6570;&#x7EC4;</h2>
<p>Pine &#x4E2D;&#x7684;&#x6570;&#x7EC4;&#x7531;&#x6570;&#x7EC4; id &#x6807;&#x8BC6;&#x3002;&#x6CA1;&#x6709;&#x8868;&#x793A;&#x6570;&#x7EC4; id &#x7684;&#x5355;&#x4E00;&#x7C7B;&#x578B;&#xFF0C;&#x800C;&#x662F;&#x53CD;&#x6620;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x7C7B;&#x578B;&#x7684;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x7684;&#x91CD;&#x8F7D;&#x7248;&#x672C;&#x3002;&#x8FD9;&#x4E9B;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x662F;&#x901A;&#x8FC7;&#x5C06; [] &#x540E;&#x7F00;&#x9644;&#x52A0;&#x5230;&#x6570;&#x7EC4;&#x4E2D;&#x5141;&#x8BB8;&#x7684;&#x56DB;&#x79CD;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x4E4B;&#x4E00;&#x6765;&#x6784;&#x9020;&#x7684;&#xFF1A;</p>
<ul>
<li>int[]</li>
<li>float[]</li>
<li>bool[]</li>
<li>color[]</li>
</ul>
<h2 id="void">void</h2>
<p>Pine Script &#x4E2D;&#x6709; void &#x7C7B;&#x578B;&#x3002;&#x5927;&#x591A;&#x6570;&#x4EA7;&#x751F;&#x526F;&#x4F5C;&#x7528;&#x7684;&#x51FD;&#x6570;&#x548C;&#x6CE8;&#x89E3;&#x51FD;&#x6570;&#x8FD4;&#x56DE; void&#x3002;&#x4F8B;&#x5982;&#xFF0C; strategy.entry&#xFF0C;plotshape &#x7B49;&#x3002;</p>
<p>void &#x7ED3;&#x679C;&#x4E0D;&#x80FD;&#x7528;&#x4E8E;&#x4EFB;&#x4F55;&#x7B97;&#x672F;&#x8868;&#x8FBE;&#x5F0F;&#x6216;&#x8D4B;&#x503C;&#x7ED9;&#x53D8;&#x91CF;&#x3002;</p>
<h2 id="na-&#x503C;">(na &#x503C;)</h2>
<p>&#x5728; Pine &#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x7279;&#x6B8A;&#x7684;&#x5185;&#x7F6E;&#x53D8;&#x91CF; na&#xFF0C;&#x5B83;&#x662F;&#x4E0D;&#x53EF;&#x7528;&#x7684;&#x9996;&#x5B57;&#x6BCD;&#x7F29;&#x5199;&#xFF0C;&#x610F;&#x601D;&#x662F;&#x8868;&#x8FBE;&#x5F0F;&#x6216;&#x53D8;&#x91CF;&#x6CA1;&#x6709;&#x503C;&#x3002;&#x8FD9;&#x4E0E; Java &#x4E2D;&#x7684; null &#x6216; Python &#x4E2D;&#x7684; None &#x975E;&#x5E38;&#x76F8;&#x4F3C;&#x3002;</p>
<p>&#x5173;&#x4E8E; na &#x503C;&#xFF0C;&#x6709;&#x4E00;&#x4E9B;&#x4E8B;&#x60C5;&#x9700;&#x8981;&#x4E86;&#x89E3;&#x3002;&#x9996;&#x5148;&#xFF0C;na &#x503C;&#x53EF;&#x4EE5;&#x81EA;&#x52A8;&#x8F6C;&#x6362;&#x4E3A;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7C7B;&#x578B;&#x3002;</p>
<p>&#x5176;&#x6B21;&#xFF0C;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;Pine &#x7F16;&#x8BD1;&#x5668;&#x65E0;&#x6CD5;&#x81EA;&#x52A8;&#x63A8;&#x65AD; na &#x503C;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x56E0;&#x4E3A;&#x6709;&#x591A;&#x79CD;&#x81EA;&#x52A8;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x89C4;&#x5219;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>myVar = na // Compilation error!
</code></pre><p>&#x5728;&#x8FD9;&#x91CC;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x65E0;&#x6CD5;&#x786E;&#x5B9A; myVar &#x662F;&#x5426;&#x5C06;&#x7528;&#x4E8E;&#x7ED8;&#x5236;&#x67D0;&#x4E9B;&#x5185;&#x5BB9;&#xFF0C;&#x4F8B;&#x5982; plot(myVar) &#x5176;&#x7C7B;&#x578B;&#x4E3A;series float&#xFF0C;&#x6216;&#x5C06;&#x67D0;&#x4E9B; label &#x5176;&#x7C7B;&#x578B;&#x8BBE;&#x7F6E;&#x4E3A; series string&#xFF0C;&#x6216;&#x7528;&#x4E8E;&#x5176;&#x4ED6;&#x76EE;&#x7684;&#x3002;&#x6B64;&#x7C7B;&#x60C5;&#x51B5;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x4EE5;&#x4E0B;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x4E4B;&#x4E00;&#x660E;&#x786E;&#x89E3;&#x51B3;&#xFF1A;label.set_text(lb, text=myVar)</p>
<pre><code>float myVar = na
</code></pre><p>&#x6216;&#x8005;&#xFF1A;</p>
<pre><code>myVar = float(na)
</code></pre><p>&#x8981;&#x6D4B;&#x8BD5;&#x67D0;&#x4E2A;&#x503C;&#x662F;&#x5426;&#x4E0D;&#x53EF;&#x7528;&#xFF0C;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x7279;&#x6B8A;&#x51FD;&#x6570;&#xFF1A;na&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>myClose = na(myVar) ? 0 : close
</code></pre><p>&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x8FD0;&#x7B97;&#x7B26; == &#x6765;&#x6D4B;&#x8BD5; na &#x503C;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E0D;&#x4FDD;&#x8BC1;&#x80FD;&#x5DE5;&#x4F5C;&#x3002;</p>
<h2 id="tuples-&#x5143;&#x7EC4;">Tuples &#x5143;&#x7EC4;</h2>
<p>&#x5728; Pine Script &#x4E2D;&#xFF0C;&#x5BF9;&#x5143;&#x7EC4;&#x7C7B;&#x578B;&#x7684;&#x652F;&#x6301;&#x6709;&#x9650;&#x3002;&#x5143;&#x7EC4;&#x662F;&#x4E00;&#x4E2A;&#x4E0D;&#x53EF;&#x53D8;&#x7684;&#x503C;&#x5E8F;&#x5217;&#xFF0C;&#x5F53;&#x51FD;&#x6570;&#x5FC5;&#x987B;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x53D8;&#x91CF;&#x4F5C;&#x4E3A;&#x7ED3;&#x679C;&#x65F6;&#x4F7F;&#x7528;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>calcSumAndMul(a, b) =&gt;
    sum = a + b
    mul = a * b
    [sum, mul]
</code></pre><p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x51FD;&#x6570;&#x7684;&#x6700;&#x540E;&#x4E00;&#x6761;&#x8BED;&#x53E5;&#x6709;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;&#x3002;&#x5143;&#x7EC4;&#x5143;&#x7D20;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#x3002;&#x8FD8;&#x6709;&#x4E00;&#x79CD;&#x7279;&#x6B8A;&#x7684;&#x8BED;&#x6CD5;&#x7528;&#x4E8E;&#x8C03;&#x7528;&#x8FD4;&#x56DE;&#x5143;&#x7EC4;&#x7684;&#x51FD;&#x6570;&#x3002;&#x4F8B;&#x5982;&#xFF0C;calcSumAndMul &#x51FD;&#x6570;&#x5FC5;&#x987B;&#x6309;&#x5982;&#x4E0B;&#x65B9;&#x5F0F;&#x8C03;&#x7528;&#xFF1A;</p>
<pre><code>[s, m] = calcSumAndMul(high, low)
</code></pre><p>&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x503C; sum &#x548C; mul &#x5C06;&#x88AB;&#x5199;&#x5165;&#x5916;&#x90E8;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x53D8;&#x91CF; s &#x548C; m&#x3002;</p>
<h2 id="&#x7C7B;&#x578B;&#x8F6C;&#x6362;">&#x7C7B;&#x578B;&#x8F6C;&#x6362;</h2>
<p>Pine Script &#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x81EA;&#x52A8;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x673A;&#x5236;&#x3002;&#x5728;&#x4E0B;&#x56FE;&#x4E2D;&#xFF0C;&#x7BAD;&#x5934;&#x8868;&#x793A; Pine &#x7F16;&#x8BD1;&#x5668;&#x81EA;&#x52A8;&#x5C06;&#x4E00;&#x79CD;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x4E3A;&#x53E6;&#x4E00;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x80FD;&#x529B;&#xFF1A;</p>
<p><img src="../img/Type_cast_rules_v4.svg" alt="&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x56FE;"></p>
<p>&#x4F8B;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;)
plotshape(series=close)
</code></pre><p>&#x51FD;&#x6570; plotshape &#x7684; series &#x53C2;&#x6570;&#x7C7B;&#x578B;&#x4E3A; series bool&#x3002;&#x4F46;&#x662F;&#x8BE5;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x4F20;&#x5165;&#x7684; close &#x662F; series float &#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;&#x3002;&#x7C7B;&#x578B;&#x4E0D;&#x5339;&#x914D;&#xFF0C;&#x4F46;&#x81EA;&#x52A8;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x89C4;&#x5219; series float &#x2192; series bool&#xFF08;&#x89C1;&#x56FE;&#x8868;&#xFF09;&#x8FDB;&#x884C;&#x4E86;&#x6B63;&#x786E;&#x7684;&#x8F6C;&#x6362;&#x3002;</p>
<p>&#x6709;&#x65F6;&#x6CA1;&#x6709;&#x81EA;&#x52A8; X &#x2192; Y &#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x89C4;&#x5219;&#x3002;&#x5BF9;&#x4E8E;&#x8FD9;&#x4E9B;&#x60C5;&#x51B5;&#xFF0C;Pine v4 &#x4E2D;&#x5F15;&#x5165;&#x4E86;&#x663E;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x51FD;&#x6570;&#x3002;&#x4ED6;&#x4EEC;&#x662F;&#xFF1A;(&#x8BD1;&#x8005;&#xFF1A;&#x539F;&#x6587;&#x8FD9;&#x91CC;&#x6709;&#x94FE;&#x63A5;&#xFF0C;&#x5EFA;&#x8BAE;&#x624B;&#x52A8;&#x5728;&#x8BED;&#x6CD5;&#x6587;&#x6863;&#x641C;&#x8FD9;&#x51E0;&#x4E2A;&#x51FD;&#x6570;)</p>
<ul>
<li>int</li>
<li>float</li>
<li>string</li>
<li>bool</li>
<li>color</li>
<li>line</li>
<li>label</li>
</ul>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;)
len = 10.0
s = sma(close, len) // Compilation error!
plot(s)
</code></pre><p>&#x6B64;&#x4EE3;&#x7801;&#x65E0;&#x6CD5;&#x7F16;&#x8BD1;&#x5E76;&#x51FA;&#x73B0;&#x9519;&#x8BEF;&#xFF1A;<code>Add to Chart operation failed, reason: line 4: Cannot call `sma` with arguments (series[float], const float); available overloads: sma(series[float], integer) =&gt; series[float];</code> &#x7F16;&#x8BD1;&#x5668;&#x663E;&#x793A;&#x867D;&#x7136; len &#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x662F; const float&#xFF0C;&#x4F46; sma &#x51FD;&#x6570;&#x9700;&#x8981;&#x4E00;&#x4E2A; integer&#x3002;sma &#x51FD;&#x6570;&#x6CA1;&#x6709;&#x5C06; const float &#x81EA;&#x52A8;&#x8F6C;&#x6362;&#x6210; integer&#xFF0C;&#x4F46;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x663E;&#x5F0F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x51FD;&#x6570;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF1A;</p>
<pre><code>//@version=4
study(&quot;My Script&quot;)
len = 10.0
s = sma(close, int(len))
plot(s)
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="5line.html" class="navigation navigation-prev " aria-label="Previous page: 换行">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="7operator.html" class="navigation navigation-next " aria-label="Next page: 运算符">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"类型系统","level":"1.4.6","depth":2,"next":{"title":"运算符","level":"1.4.7","depth":2,"path":"fundamentals/7operator.md","ref":"./fundamentals/7operator.md","articles":[]},"previous":{"title":"换行","level":"1.4.5","depth":2,"path":"fundamentals/5line.md","ref":"./fundamentals/5line.md","articles":[]},"dir":"ltr"},"config":{"plugins":["livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"剑客","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Pine Script 用户手册中文版","language":"zh","gitbook":"*","description":"Pine Script 文档中文翻译"},"file":{"path":"fundamentals/6type.md","mtime":"2021-06-02T13:51:21.021Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-06-14T07:42:18.199Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

